﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CNdotnet.Ezsocio.ContactService
{
    public class EmailContactModule
    {
        public static event EventHandler<ServedEventArgs> EmailServed;
        public static event EventHandler<FetchEventArgs> EmailFetch;
        
        public List<string> GetAvailableEmails()
        {
            ServedEventArgs e = new ServedEventArgs(new List<string>());
            OnEmailServed(e);

            return e.Data;
        }

        public List<ContactMember> FetchContact(string account, string password)
        {
            FetchEventArgs e = new FetchEventArgs(new List<ContactMember>());
            e.Account = account;
            e.Password = password;
            OnEmailFetch(e);

            return e.Data;
        }

        protected static void OnEmailServed(ServedEventArgs e)
        {
            EventHandler<ServedEventArgs> tempHandler = EmailServed;
            if (tempHandler != null)
            {
                EmailServed(null, e);
            }
        }

        protected static void OnEmailFetch(FetchEventArgs e)
        {
            EventHandler<FetchEventArgs> tempHandler = EmailFetch;
            if (tempHandler != null)
            {
                EmailFetch(null, e);
            }
        }
    }
}
